/**
 * @Author: Sagan
 * @Date: 2020/09/16 19:10
 */
package module

import (
	"gitee.com/big_meteor/godash/lang"
	"gitee.com/big_meteor/godash/number"
	"reflect"
)

// 是否为数字
// 支持的类型：float、int、uint
func Int(v interface{}) bool {
	kind := lang.GetType(v)

	sType := []reflect.Kind{
		reflect.Float32, reflect.Float64,
		reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
		reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr,
	}

	for i := 0; i < len(sType); i++ {
		if kind == sType[i] {
			return true
		}
	}

	if kind == reflect.String {
		v, _ = lang.GetValue(v)
		return number.IsNum(v.(string))
	}

	return false
}
